update AD_SysConfig set value = '127.0.0.1:2181' where AD_SysConfig_ID=1000280;
update AD_SysConfig set value = '127.0.0.1' where AD_SysConfig_ID=1000019;
update AD_SysConfig set value = 'noreply@winit.com.cn' where AD_SysConfig_ID=1000021;
update AD_SysConfig set value = 'abc' where  AD_SysConfig_ID=1000162;
update AD_SysConfig set value = '127.0.0.1' where  AD_SysConfig_ID=1000035;
update AD_Sysconfig SET value = '127.0.0.1:2181' WHERE name='WT_MQX_CONFIG_ZK_SERVER_ADDRESSES';
update AD_Sysconfig SET value = '127.0.0.1:2181' WHERE name='dubbo.registry.address';
UPDATE AD_SYSCONFIG SET VALUE = '1290' WHERE NAME = 'dubbo.protocol.port';
update AD_Sysconfig SET value = 'http://127.0.0.1:780/openapi/service' WHERE name='WT_API_URL';
update AD_Scheduler t set t.ip= '127.0.0.1' where t.ip is not null;



update ad_user u set u.password='b6a2bec13f5654e89b7eba186067c7911a3faad2a5509cab5d97f134e57df412' where  u.name='yang.ou';
update ad_user set isactive='Y' where name='qiongjierui@163.com';

UPDATE wt_scheduler_trigger SET ip = '127.0.0.1',CRON_EXPRESSION = '0/59 * * * * ?';
UPDATE ad_sysconfig SET VALUE = 'http://127.0.0.1:1380/winit-dep-web/' WHERE name = 'DEP_API_SERVER_ADDRESS';
UPDATE wt_scheduler_param SET task_url=REPLACE(task_url,'127.0.0.1:8080','127.0.0.1:1380');
UPDATE wt_dep_current_batch a SET a.gen_batch = 1,syn_batch=1;
TRUNCATE  TABLE wt_dep_send_msg;
TRUNCATE  TABLE wt_dep_send_msg_receiver;
TRUNCATE  TABLE wt_dep_send_msg_batch;
TRUNCATE  TABLE wt_dep_receive_msg;
TRUNCATE  TABLE wt_dep_receive_msg_batch;
TRUNCATE  TABLE wt_dep_msg_transport_log;
TRUNCATE  TABLE wt_sync_lock;
TRUNCATE TABLE WT_SCHEDULER_LOG;
TRUNCATE TABLE WT_ITEMINFO;


update ad_user set password='b6a2bec13f5654e89b7eba186067c7911a3faad2a5509cab5d97f134e57df412' where name = 'yang.ou';

delete from wt_warehousestorage;

insert into wt_warehousestorage (
  M_PRODUCT_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, UPDATED, UPDATEDBY,
  QTYONHAND, QTYRESERVED, QTYORDERED, DATELASTINVENTORY, M_ATTRIBUTESETINSTANCE_ID, WT_WAREHOUSESTORAGE_ID,
  M_WAREHOUSE_ID, AVGSALES, AVGSTORAGEDAYS, QTYHISIN, QTYHISOUT, ISPROHIBITOUTBOUND, SKU, C_BPARTNER_ID,
  STOCKOUTRATE, LEADTIME, RMENTLEADCOUNT, SAFETYSTOCK, FIRSTSALETIME, QTYSHARESTORAGE, QTYSELLHISOUT, FIRSTSHELVETIME)
select pid,cid,org_id,'Y',sysdate,cby,sysdate,uby,
  cnt,0,0,null,0,wt_warehousestorage_seq.nextval,
  wid,0,0,0,0,'N',psku,bpid,
  null, null, null, null, null,0,0,sysdate
from(
  select max(p.m_product_id) pid,max(p.ad_client_id) cid,max(p.ad_org_id) org_id,max(i.CREATEDBY) cby,max(i.UPDATEDBY) uby,
    count(1) cnt,l.m_warehouse_id wid,max(p.sku) psku,max(p.c_bpartner_id) bpid
  from wt_storageitem i
  left join m_product p on p.m_product_id=i.m_product_id
  left join m_locator l on i.m_locator_id=l.m_locator_id
  left join m_warehouse w on w.m_warehouse_id=l.m_warehouse_id
  where status='FSC' and w.m_warehouse_id is not null
  group by p.m_product_id,l.m_warehouse_id
);



UPDATE M_WAREHOUSE SET STATUSSWITCHTIME = 0;


-- delete from WT_WarehouseStorage where sku like 'RM%';
-- DELETE FROM WT_StorageItem WHERE M_PRODUCT_ID IN(SELECT M_PRODUCT_ID FROM  M_Product  where sku like 'RM%');
-- delete from M_Product  where sku like 'RM%';



insert into WT_EBayAccount (WT_EBAYACCOUNT_ID, AD_CLIENT_ID, AD_ORG_ID, ISACTIVE, CREATED, CREATEDBY, UPDATED, UPDATEDBY, AD_USER_ID, C_BPARTNER_ID, USERID, USERIDCHANGED, USERIDLASTCHANGED, STATUS, VATSTATUS, ISALLOWPAYMENTEDIT, EMAIL, AUTHTOKEN, EIASTOKEN, EXPIREDATE, VERSION, ISNEWUSER, SITE, ISVALID, EBAYACCOUNT_FOR_SHORT)
values (999999999, 11, 1000000, 'Y', to_date('12-01-2015 11:36:58', 'dd-mm-yyyy hh24:mi:ss'), 1007505, to_date('30-01-2015 08:09:55', 'dd-mm-yyyy hh24:mi:ss'), 1007505, 1000138, 1000019, 'bessky_cn', 'N', to_date('28-01-2013 06:27:57', 'dd-mm-yyyy hh24:mi:ss'), 'Confirmed', 'NoVATTax', 'N', '12312313@126.com', '<CLOB>', 'nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6AEloulCJCFog6dj6x9nY', to_date('05-12-2016 03:36:53', 'dd-mm-yyyy hh24:mi:ss'), null, 'N', 'HongK', 'Y', null);


VARIABLE jobno number;
begin
  DBMS_JOB.SUBMIT(:jobno,'PRO_DEP_RECEIVE_MSG_COPY;',SYSDATE,'sysdate+1/24/60');
  commit;
end;

/

DECLARE
cursor c_seq is
select SEQUENCE_NAME||','||last_number,max_value,last_number  from user_sequences
order by SEQUENCE_NAME;
p_sequenceName varchar2(50);
p_sequenceName1 varchar2(50);
p_current_seq_value  varchar2(50);
p_seqNextValue varchar2(50);
p_diff_value number;
p_max_value NUMBER;
p_lastnumber NUMBER;
a varchar2(10);
BEGIN
  open c_seq;
 LOOP
    fetch c_seq into p_sequenceName,p_max_value,p_lastnumber;
    exit when c_seq%notfound;
    p_sequenceName1:=SUBSTR(p_sequenceName,0,INSTR(p_sequenceName,',')-1);
    p_current_seq_value:=SUBSTR(p_sequenceName,INSTR(p_sequenceName,',')+1);
    p_seqNextValue:=to_number(SUBSTR(p_sequenceName,INSTR(p_sequenceName,',')+1));
    IF (p_max_value-p_lastnumber)>= 2000000 THEN
       p_seqNextValue:=p_seqNextValue+1000000;
    ELSIF  ((p_max_value-p_lastnumber) >= 200000 AND (p_max_value-p_lastnumber) < 2000000) THEN
       p_seqNextValue:=p_seqNextValue+100000;
    ELSIF   ((p_max_value-p_lastnumber) >= 50000 AND (p_max_value-p_lastnumber) < 200000) THEN
        p_seqNextValue:=p_seqNextValue+10000;
     ELSIF   ((p_max_value-p_lastnumber) >= 10000 AND (p_max_value-p_lastnumber) < 50000) THEN
        p_seqNextValue:=p_seqNextValue+1000;
    ELSIF   ((p_max_value-p_lastnumber) >= 200 AND (p_max_value-p_lastnumber) < 10000) THEN
         p_seqNextValue:=p_seqNextValue+20;
    ELSIF   ((p_max_value-p_lastnumber) >= 20 AND (p_max_value-p_lastnumber) < 200) THEN
         p_seqNextValue:=p_seqNextValue+2;
    END IF;
    p_diff_value:=to_number(p_seqNextValue)-to_number(p_current_seq_value);
       execute immediate'alter sequence '|| p_sequenceName1|| ' increment by '|| abs(p_diff_value)  ||' nocache';
       execute immediate 'select '||p_sequenceName1||'.nextval from dual' into a;
       execute immediate 'alter sequence '|| p_sequenceName1|| ' increment by 1 cache 20';
  END LOOP;
   exception when others then
    dbms_output.put_line('sqlerrm='||SQLERRM);
END;

/

exit
